The monitor card allows you to trace the actions of the inference engine. It includes a trace field which shows the actions taken by the inference engine, a facts field which shows the facts asserted and their values, and a stack field which shows the rules and facts to be processed. The monitor card also enables you to step through the inference process. These features make the monitor card an effective debugging tool. Figure 19 shows the monitor card.
To use the monitor card you should first set the check boxes "trace" and "step" to turn these features on or off. Next, you should select backward or forward chaining. If you select backward chaining, you must enter the goal into the
"goal" field. Then, click on the "init" button to initialize the system (or enter carriage return in the goal field). To continue when "stepping" through the session, click on the "continue" button.
The trace feature controls the "Trace" field, the "Facts" field, and the "Stack" field. If it is on, the inference engine will enter the appropriate trace data in these fields.
NOTE: The "Stack" field on the monitor card grows down. Items are pushed and popped at the bottom of the "Stack" field.
The step feature allows you to break after each major action by the inference engine. If it is on, the inference engine will go to the monitor card and wait for you to click on "continue" to begin again.
The arrow and bar (->|) button on the monitor allows you to return to the init, fact, or conclusion card where you last clicked on a bar and arrow (|<-) button. Remember that if you go to the monitor card from a fact card, you should return to the fact card and answer any questions posed by it. If you use the "continue" button on the monitor card to begin again, the system will NOT return to the fact card and the fact that should have been asserted at that card will not be asserted.
As with the compiler card, feel free to modify the monitor card in any way that suits you. The trace and step functions are controlled by special global variables as follows:
ILSI_TRACE - If set to a string defining a field, it will cause the inference engine to post trace messages in that field. Setting the variable to null (""), disables the activity trace function. The field specification must be enclosed in quotes so that HyperTalk will not attempt to evaluate it.
ILSI_FACTS - If set to a string defining a field, it will cause the inference engine to post fact names and their values into that field as they are asserted. Setting the variable to null (""), disables the fact trace function. The field specification must be enclosed in quotes so that HyperTalk will not attempt to evaluate it.
ILSI_STACK - If set to a string defining a field, it will cause the inference engine to display the stack in that field. Setting the variable to null (""), disables the stack trace function. The field specification must be enclosed in quotes so that HyperTalk will not attempt to evaluate it.
ILSI_STEP - If set to the name of a card, it will cause the inference engine to operate in step mode and to return to the named card at each step. Setting the variable to null (""), disables the step function.
The monitor card uses the "scrollToBottom" XCMD to scroll to the bottom of fields on the card. The format for that XCMD is as follows:
SCROLLTOBOTTOM field_specification
The XCMD will automatically calculate the proper scroll setting based on the size of the window, the text height, and the number of lines of text. The field specification must be enclosed in quotes so that HyperTalk will not attempt to evaluate it.